<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/png" href="https://i.loli.net/2018/05/11/5af50d7591443.jpg">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>加华国际英语—雅思能力测试</title>
    <link href="https://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/jh/question/index.css">
    <link href="https://cdn.bootcss.com/layer/2.3/skin/layer.css" rel="stylesheet">
</head>

<body>
    <div id="app">
        <div class="logo">
            <img src="https://i.loli.net/2018/10/23/5bce93c427aa8.png" alt="logo.png" title="logo.png" class="am-img-thumbnail" />
      </div>
            <div class="login">
                <ul>
                    <li>
                        <img src="https://i.loli.net/2018/10/23/5bce93c40155a.png" class="am-img-thumbnail" />
                        <input type="text" placeholder="请输入编号" v-model="code">
                    </li>
                </ul>
                <button type="button" class="am-btn submit" @click="toQuestion()">开始测试</button>
            </div>
        </div>
</body>
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/amazeui/2.7.2/js/amazeui.min.js"></script>
<script src="http://lib.h-ui.net/jquery.cookie/1.4.1/jquery.cookie.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script type="text/javascript">
function go() {
    const cookieTime = new Date();
    cookieTime.setTime(cookieTime.getTime() + 45 * 60 * 1000);
    $.cookie('user_cookie', app.code, {
        expires: cookieTime,
        path: '/jh/question'
    });
    window.location.href = "/jh/question/questions";
}
var app = new Vue({
    el: '#app',
    data: {
        code: ""
    },
    created() {

    },
    mounted() {

    },
    methods: {
        toQuestion() {
            if (this.code == '') {
                layer.msg('编号错误')
                return
            }
            var codes = ["jiahua", "123", "sean", "trump"]
            var code = codes[2];
            for (var idx = 0; idx < codes.length; idx++) {
                var code = codes[idx]
                // console.log(code)
                if (code == this.code) {
                    // console.log('match')
                    var index = layer.load(0, { shade: false }); //0代表加载的风格，支持0-2
                    //loading层
                    var index = layer.load(2, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    go()
                    return
                }
            }
            // alert('编号错误')
            layer.msg('编号错误')
            return
        }
    }
})
</script>

</html>